package com.lin.csdn.utils;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class InputSteam {
    BaseLogger baseLogger=new BaseLogger();
//输入工具
    public String getContext(File url){
        StringBuilder s=new StringBuilder();
        try (InputStream input = new FileInputStream(url)) {
            Reader reader = new InputStreamReader(input, StandardCharsets.UTF_8);
            for (;;) {
                int n = reader.read(); // 反复调用read()方法，直到返回-1
                if (n == -1) {
                    break;
                }
                s.append((char)n);
            }
            reader.close();
        } catch (IOException e) {
            baseLogger.errorLog(String.valueOf(e));
        }
        return String.valueOf(s);
    }
}
